package com.menhai.personmanagement.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.menhai.personmanagement.entity.Codelist;
import com.menhai.personmanagement.entity.User;
import com.menhai.personmanagement.entity.co.MbReportCardCO;
import com.menhai.personmanagement.entity.vo.MbReportCardVo;
import com.menhai.personmanagement.services.ICodelistService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author shikun
 * @since 2021-11-24
 */

@Slf4j
@RestController
@RequestMapping("/codelist")
public class CodelistController {

     @Autowired
     private ICodelistService codelistService;


     /**
      * @describe
      * @param kindCode
      * @Return java.util.List<com.menhai.personmanagement.entity.Codelist>
      * @Date 2021/11/25 8:57
      * @author shikun
      */
     @GetMapping("/selectByCodeKindCode")
     public List<Codelist> selectByCodeKindCode(@Param("kindCode") String kindCode){
          List<Codelist> list = codelistService.selectByCodeKindCode(kindCode);
          return list;
     }

     @RequestMapping("/findOneType")
     public List findOneType(@Param("type") String type){
          return codelistService.findOneType(type);
     }

     @RequestMapping("/getHospital")
     public List<Codelist> getHospital(){
          return codelistService.getHospital();
     }

     @RequestMapping("/getHospitalTwo")
     public List<Codelist> getHospitalTwo(@Param("code") String code){
          return codelistService.getHospitalTwo(code);
     }

     @RequestMapping("/getHospitalThree")
     public List<Codelist> getHospitalThree(@Param("code") String code){
          return codelistService.getHospitalThree(code);
     }

     @RequestMapping("/getCurrentUser")
     public List getCurrentUser(@RequestHeader("level") String level){
          System.out.println(level);
          return codelistService.getHospitalThree(level);
     }

     /**
      * @describe 医院下级
      * @param codeValue
      * @Return java.util.List<com.menhai.personmanagement.entity.Codelist>
      * @Date 2021/12/16 10:56
      * @author shikun
      */
     @RequestMapping("/getLowerlevel")
     public List<Codelist> getLowerlevel(@Param("codeValue") String codeValue){
          return codelistService.getLowerlevel(codeValue);
     }

     /**
      * @describe 得到所有镇医院
      * @param
      * @Return java.util.List<com.menhai.personmanagement.entity.Codelist>
      * @Date 2021/12/16 14:27
      * @author shikun
      */
     @RequestMapping("/getZhenHospital")
     public List<Codelist> getZhenHospital(){
          return codelistService.getZhenHospital();
     }

     /**
      * @describe 得到所有村医院
      * @param
      * @Return java.util.List<com.menhai.personmanagement.entity.Codelist>
      * @Date 2021/12/16 14:31
      * @author shikun
      */
     @RequestMapping("/getChunHospital")
     public List<Codelist> getChunHospital(){
          return codelistService.getChunHospital();
     }
     
     /**
      * 获取字典维护二级菜单
      * @return
      */
     @RequestMapping("/getKindCodeList")
     public List<Codelist> getKindCodeList(){
          return codelistService.getKindCodeList();
     }
     
     /**
      * 获取字典列表
      * @param codelist
      * @return
      */
    @RequestMapping("/getCodeList")
 	public IPage<Codelist> getCodeList(Codelist codelist){
 		return codelistService.getCodeList(codelist);
 	}
    
    /**
     * 新建字典
     * @param request
     * @param response
     * @param codelist
     * @return
     */
    @RequestMapping("/addCode")
    public Object selectcounty(HttpServletRequest request, HttpServletResponse response,Codelist codelist){    	 
		return codelistService.addCode(codelist);
    }
    
    
   /**
    * 删除字典
    * @param request
    * @param response
    * @return
    */
    @RequestMapping("/deleteCode")
    public Object selectcounty(HttpServletRequest request, HttpServletResponse response){ 
    	String codelistId = request.getParameter("codelistId");
		return codelistService.delete(codelistId);
    }
    
    /**
     * 编辑字典
     * @param request
     * @param response
     * @param codelist
     * @return
     */
    @RequestMapping("/updateCode")
    public Object updateCode(HttpServletRequest request, HttpServletResponse response,Codelist codelist){ 
		return codelistService.updateCode(codelist);
    }


    @RequestMapping("/updateCodeAll")
    public int updateCodeAll (@RequestBody Codelist codelist){
        int flag = codelistService.updateCodeAll(codelist);
        return flag;
    }

    @RequestMapping("/adddateCodelowerlevel")
    public int adddateCodelowerlevel (@RequestBody Codelist codelist){
        int flag = codelistService.adddateCodelowerlevel(codelist);
        return flag;
    }


    @RequestMapping("/deleteOwnthefollowing")
    public int deleteOwnthefollowing (@RequestBody Codelist codelist){
        int flag = codelistService.deleteOwnthefollowing(codelist);
        return flag;
    }

}
